(:
  A procedure to select the contents of the "chat" interventions
:)
declare boundary-space strip;
import module namespace
    jj = "http://kumquat.emse.fr/utilitaires"
    at "jjutils.xq" ; 


<display>{

let $t := doc($arguments[1])/display
let $users := $t/item/info[@name="user"]/text()
let $usersdistinct := fn:distinct-values($users)
for $user in $usersdistinct
let $count := fn:count($t/item[info[@name="user"]/text() = $user])
order by $count descending
return
<item>
<info name="User">{$user}</info>
<info name="Total">{$count}</info>
</item>

}</display>
